
package trim.differentmaterials.algorithms;

import trim.*;
import trim.common.result.*;
import trim.common.inputdata.*;
import trim.differentmaterials.core.*;
import trim.differentmaterials.generator.columns.*;
import trim.differentmaterials.coefficients.*;
import trim.differentmaterials.generator.core.*;

/**
 *
 * @author Podorov Alexander
 */

public class Mwem extends Trim
{
    public TrimResult solve(InputData inputData) throws NoSolutionsException
    {
        TrimCore core = new TrimCore(inputData);
        Coefficients coefficients = new ErnmCoefficients();        
        Generator generator = new Generator(core, coefficients);

        for (int i = 0; i < core.getMaterialCount(); i++)
        {           
            RealPattern pattern = (RealPattern)generator.getMinimumRestPatternIn(i);
            pattern.setCount(core.getMaterialStock()[i].getCount());
            core.getPatterns().add(pattern);
        }
        
        return core.getTrimResult();
    }

    public String getName()
    {
        return "MWEM (Minimum wastes, exact materials)";
    }

    public String getVersion()
    {
        return "1.0.0";
    }

    public String getDescription()
    {
        return "Раскрой заданного количества материалов c наименьшими потерями (очень грубый алгоритм)";
    }
}
